package com.shzu.jwc.ty.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.shzu.jwc.ty.bean.UserSys;
import com.shzu.jwc.ty.bean.UserSysExample;
import com.shzu.jwc.ty.common.MD5Util;
import com.shzu.jwc.ty.dao.UserSysMapper;

@Service
public class UserUpdatepassservice {

	@Autowired
	UserSysMapper mapper;
	
	public Integer updatepass(String username, String password) {
		UserSysExample example=new UserSysExample();
		UserSysExample.Criteria criteria=example.createCriteria();
		criteria.andUsernameEqualTo(username);
		UserSys usersys=mapper.selectByExample(example).get(0);
		usersys.setPassword(MD5Util.encrypt(password));
		return mapper.updateByPrimaryKey(usersys);
	}
	
	public Integer isextis(String username, String password) {
		UserSysExample example=new UserSysExample();
		UserSysExample.Criteria criteria=example.createCriteria();
		criteria.andUsernameEqualTo(username);
		criteria.andPasswordEqualTo(MD5Util.encrypt(password));
		return (int) mapper.countByExample(example);
	}
}
